
//==============echart tool 工具方法     start==========================
import echarts from 'echarts'

/**
 * 公用方法封装
 * create by wanqile 2018.3.2
 * */

//获得默认 option对象
export function getDefaultOption() {
    var option = {
        color: ["#22bae8", "#02E942", "#FFA800"],
        title: {
            text: '',
            left: 'center',
            textStyle: {
                fontSize: '36',
                fontWeight: '500',
                color: '#fff'
            }
        },

        tooltip: {
            trigger: 'axis',
            axisPointer: { // 坐标轴指示器，坐标轴触发有效
                type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
            },
            textStyle: {
                fontSize: '36',
                fontWeight: '500',
                color: '#bbb'
            }
        },
        grid: {
            left: '1%',
            right: '1%',
            bottom: '1%',
            top: '5%',
            containLabel: true
        },
        xAxis: [{
            type: 'category',
            data: [], // 名称
            axisLabel: {
                show: true,
                interval: 0, // 强制显示所有标签
                //rotate: 10, // 角度
                textStyle: {
                    color: '#fff',
                    fontSize: 36
                },
                formatter:function(value) {
                    var v = value.substring(0, 4) + '...';
                    return value.length > 5 ? v : value
                }
            },
            axisLine: {
                lineStyle: {
                    color: '#bbb',
                    width: 2, // 这里是为了突出显示加上的
                }
            }
        }],
        yAxis: [{
            type: 'value',
            min: 0,
            splitLine: {
                //show: false
            }, //去除网格线
            nameTextStyle: {
                color: '#bbb',
                fontSize: 36
            },
            axisLabel: {
                formatter: '{value}',
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#bbb'
                }
            },
            axisLine: {
                show: true,
                lineStyle: {
                    color: '#bbb',
                    width: 2, // 这里是为了突出显示加上的
                }
            },
            axisTick: {
                show: false,
            }
        }],
        series: [{
            name: '',
            type: 'bar',
            data: [],
            barWidth: '30%',//柱图宽度
            barMinHeight:10,
            barMaxWidth:45,
            itemStyle: {
                normal: {
                    barBorderRadius: 6,
                    label: {
                        show: false,
                        position: 'top',
                        textStyle: {
                            color: '#fff',
                            fontSize: '36',
                            fontFamily: '微软雅黑',
                        },
                    },
                }
            }
        }]
    };
    return option;
}


/**
 * 根据图形 type 获取模板 Option
 * @param type
 * @returns {*}
 */
export function chooseModelOption(type) {
    if (type == 'bar') {
        //柱状 此处和默认option对象是一致的
        const barModel = {
            color: ["#22bae8", "#02E942", "#FFA800"],
            title: {
                text: '',
                left: 'center',
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#fff'
                }
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: { // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
                },
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#bbb'
                }
            },
            grid: {
                left: '1%',
                right: '1%',
                bottom: '1%',
                top: '5%',
                containLabel: true
            },
            xAxis: [{
                type: 'category',
                data: [], // 名称
                nameTextStyle:{
                    fontSize:36,
                },
                axisLabel: {
                    show: true,
                    interval: 0, // 强制显示所有标签
                    //rotate: 30, // 角度
                    textStyle: {
                        color: '#fff',
                        fontSize: 36
                    },
                    // formatter:function(value) {
                    //     var v = value.substring(0, 4)+'...';
                    //     return value.length > 4 ? v : value
                    // }
                },
                axisLine: {
                    lineStyle: {
                        color: '#bbb',
                        width: 2, // 这里是为了突出显示加上的
                    }
                }
            }],
            yAxis: [{
                type: 'value',
                min: 0,
                splitLine: {
                    //show: false
                }, //去除网格线
                nameTextStyle: {
                    color: '#bbb',
                    fontSize: 36
                },
                axisLabel: {
                    formatter: '{value}',
                    textStyle: {
                        fontSize: '36',
                        fontWeight: '500',
                        color: '#bbb'
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#bbb',
                        width: 2, // 这里是为了突出显示加上的
                    }
                },
                axisTick: {
                    show: false,
                }
            }],
            series: [{
                name: '',
                type: 'bar',
                data: [],
                barWidth: '30%',//柱图宽度
                barMinHeight:10,
                barMaxWidth:45,
                itemStyle: {
                    normal: {
                        color: function(params) {
                            var index_color = params.value;
                            if(index_color*1>=0){
                                return '#22bae8';
                            }else {
                                return '#D76A62';
                            }
                        },
                        barBorderRadius: 6,
                        label: {
                            show: false,
                            position: 'top',
                            textStyle: {
                                color: '#fff',
                                fontSize: '36',
                                fontFamily: '微软雅黑',
                            },
                        },
                    }
                }
            }]
        };
        return barModel;
    } else if (type == 'line') {
        //线图
        const lineModel = {
            color: ["#fec868", "#02E942", "#FFA800"],
            title: {
                text: '',
                left: 'center',
                top:20,
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#fff'
                }
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: { // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
                },
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#bbb'
                }
            },
            grid: {
                left: '1%',
                right: '1%',
                bottom: '1%',
                top: '5%',
                containLabel: true
            },
            /*legend : {
              data: [],
              top : '8%',
              textStyle : {
                fontSize : '15',
                fontWeight : '500',
                color : '#fff'
              }
            },*/
            xAxis: [{
                type: 'category',
                data: [], // 名称
                axisLabel: {
                    show: true,
                    interval: 0, // 强制显示所有标签
                    textStyle: {
                        color: '#fff',
                        fontSize: 36
                    },
                    formatter:function(value) {
                        var v = value.substring(0, 7) + '...';
                        return value.length > 7 ? v : value
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#bbb',
                        width: 2, // 这里是为了突出显示加上的
                    }
                }
            }],
            yAxis: [{
                type: 'value',
                min: 0,
                minInterval:1,//分割为整数
                nameGap:10,//坐标轴名字与坐标轴的距离
                name:'',//坐标轴名字
                splitLine: {
                    //show: false
                }, //去除网格线
                nameTextStyle: {
                    color: '#bbb',
                    fontSize: 36
                },
                axisLabel: {
                    formatter: '{value}',
                    textStyle: {
                        fontSize: '36',
                        fontWeight: '500',
                        color: '#bbb'
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#bbb',
                        width: 2, // 这里是为了突出显示加上的
                    }
                },
                axisTick: {
                    show: false
                }
            }],
            series: [{
                name: '',
                type: 'line',
                data: [],
//                    smooth: true,
                symbolSize: 10,//拐点大小
                itemStyle: {
                    normal: {
                        lineStyle: {
                            width: 7,//折线宽度
                        },
                        label: {
                            show: false,
                            position: 'top',
                            textStyle: {
                                color: '#fff',
                                // fontWeight:'500er',
                                fontSize: '36',
                                fontFamily: '微软雅黑',
                            }
                        }
                    }
                }
            },]
        };
        return lineModel;
    } else if (type == 'pie') {
        //饼图
        const pieModel = {
            color: ['#53c1e6', '#fec868', '#fa7264', '#7853e1', '#76d6d2', '#1ba0c1', '#295c9d', '#ec915c', '#ebcb5c'],
            title: {
                text: '',
                left: 'center',
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#fff'
                }
            },
            grid: {
                left: '1%',
                right: '1%',
                bottom: '1%',
                top: '5%',
                containLabel: true
            },
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b}: {c} ({d}%)",
                textStyle: {
                    fontSize: '36',
                }
            },
            legend: {
                type: 'scroll',
                orient: 'vertical',
                right: '10%',
                top: 20,
                bottom: 20,
                data: [],
                textStyle: {
                    // fontWeight: 150,
                    fontSize: 36,
                    color: '#fff',
                    padding: 7
                }
            },
            series: [
                {
                    name: "",
                    type: 'pie',
                    radius: ['50%', '75%'],
                    center: ['30%', '50%'],
                    hoverAnimation:false,//hover动画效果关闭
                    data: [],
                    label: {
                        normal: {
                            show: false,
                            textStyle: {
                                fontWeight: 150,
                                fontSize: 36,
                                color: '#fff'
                            },
                            formatter: '{b} {d}%'
                        }
                    },
                }
            ]
        };
        return pieModel;
    } else if (type == 'bar_line') {
        //柱状图与折现图结合
        const barLineModel = {
            color: ['#53c1e6', '#fec868', '#53c1e6', '#fec868', '#76d6d2', '#1ba0c1', '#295c9d', '#ec915c', '#ebcb5c'],
            title: {
                text: '',
                left: 'center',
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#fff'
                }
            },
            grid: {
                left: '2%',
                right: '2%',
                bottom: '1%',
                top: '10%',
                containLabel: true
            },
            tooltip: {
                trigger: 'axis',
                textStyle: {
                    fontSize: '36'
                }
            },
            xAxis: [
                {
                    type: 'category',
                    data: [],
                    axisPointer: {
                        type: 'shadow'
                    },
                    axisLabel: {
                        show: true,
                        interval: 0, // 强制显示所有标签
                        textStyle: {
                            color: '#fff',
                            fontSize: 36
                        },
                        formatter:function(value) {
                            var v = value.substring(0, 7) + '...';
                            return value.length > 7 ? v : value
                        }
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#bbb',
                            width: 2, // 这里是为了突出显示加上的
                        }
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    name: '',
                    // interval: 200,
                    axisLabel: {
                        formatter: '{value}',
                        textStyle: {
                            fontSize: '36',
                            fontWeight: '500',
                            color: '#bbb'
                        }
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#bbb',
                            width: 2, // 这里是为了突出显示加上的
                        }
                    }
                },
                {
                    type: 'value',
                    name: '',
                    // min: 0,
                    // max: 25,
                    // interval: 10,
                    axisLabel: {
                        formatter: '{value}',
                        textStyle: {
                            fontSize: '36',
                            fontWeight: '500',
                            color: '#bbb'
                        }
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#bbb',
                            width: 2, // 这里是为了突出显示加上的
                        }
                    }
                }
            ],
            legend: {
                orient: 'horizontal',
                data: [],
                textStyle: {
                    fontWeight: 150,
                    fontSize: 36,
                    color: '#fff',
                    padding: 7
                }
            },
            series: []
        };
        return barLineModel;
    } else {
        //返回默认
        return getDefaultOption();
    }
}
export function chooseModelOption2(type) {
    if (type == 'bar') {
        //柱状 此处和默认option对象是一致的
        const barModel = {
            color: ["#22bae8", "#02E942", "#FFA800"],
            title: {
                text: '',
                left: 'center',
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#fff'
                }
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: { // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
                },
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#bbb'
                }
            },
            grid: {
                left: '1%',
                right: '1%',
                bottom: '1%',
                top: '5%',
                containLabel: true
            },
            xAxis: [{
                type: 'category',
                data: [], // 名称
                axisLabel: {
                    show: true,
                    interval: 0, // 强制显示所有标签
                    //rotate: 30, // 角度
                    textStyle: {
                        color: '#fff',
                        fontSize: 30
                    },
                    formatter:function(value) {
                        var v = value.substring(3, 13);
                        return value.length > 8 ? v : value
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: '#bbb',
                        width: 2, // 这里是为了突出显示加上的
                    }
                }
            }],
            yAxis: [{
                type: 'value',
                min: 0,
                splitLine: {
                    //show: false
                }, //去除网格线
                nameTextStyle: {
                    color: '#bbb',
                    fontSize: 36
                },
                axisLabel: {
                    formatter: '{value}',
                    textStyle: {
                        fontSize: '36',
                        fontWeight: '500',
                        color: '#bbb'
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#bbb',
                        width: 2, // 这里是为了突出显示加上的
                    }
                },
                axisTick: {
                    show: false,
                }
            }],
            series: [{
                name: '',
                type: 'bar',
                data: [],
                barWidth: '30%',//柱图宽度
                barMinHeight:10,
                barMaxWidth:45,
                itemStyle: {
                    normal: {
                        color: function(params) {
                            var index_color = params.value;
                            if(index_color*1>=0){
                                return '#22bae8';
                            }else {
                                return '#D76A62';
                            }
                        },
                        barBorderRadius: 6,
                        label: {
                            show: false,
                            position: 'top',
                            textStyle: {
                                color: '#fff',
                                fontSize: '36',
                                fontFamily: '微软雅黑',
                            },
                        },
                    }
                }
            }]
        };
        return barModel;
    } else if (type == 'line') {
        //线图
        const lineModel = {
            color: ["#fec868", "#02E942", "#FFA800"],
            title: {
                text: '',
                left: 'center',
                top:20,
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#fff'
                }
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: { // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
                },
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#bbb'
                }
            },
            grid: {
                left: '1%',
                right: '1%',
                bottom: '1%',
                top: '5%',
                containLabel: true
            },
            /*legend : {
              data: [],
              top : '8%',
              textStyle : {
                fontSize : '15',
                fontWeight : '500',
                color : '#fff'
              }
            },*/
            xAxis: [{
                type: 'category',
                data: [], // 名称
                axisLabel: {
                    show: true,
                    interval: 0, // 强制显示所有标签
                    textStyle: {
                        color: '#fff',
                        fontSize: 36
                    },
                    formatter:function(value) {
                        var v = value.substring(0, 7) + '...';
                        return value.length > 7 ? v : value
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#bbb',
                        width: 2, // 这里是为了突出显示加上的
                    }
                }
            }],
            yAxis: [{
                type: 'value',
                min: 0,
                minInterval:1,//分割为整数
                nameGap:10,//坐标轴名字与坐标轴的距离
                name:'',//坐标轴名字
                splitLine: {
                    //show: false
                }, //去除网格线
                nameTextStyle: {
                    color: '#bbb',
                    fontSize: 36
                },
                axisLabel: {
                    formatter: '{value}',
                    textStyle: {
                        fontSize: '36',
                        fontWeight: '500',
                        color: '#bbb'
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#bbb',
                        width: 2, // 这里是为了突出显示加上的
                    }
                },
                axisTick: {
                    show: false
                }
            }],
            series: [{
                name: '',
                type: 'line',
                data: [],
//                    smooth: true,
                symbolSize: 10,//拐点大小
                itemStyle: {
                    normal: {
                        lineStyle: {
                            width: 7,//折线宽度
                        },
                        label: {
                            show: false,
                            position: 'top',
                            textStyle: {
                                color: '#fff',
                                // fontWeight:'500er',
                                fontSize: '36',
                                fontFamily: '微软雅黑',
                            }
                        }
                    }
                }
            },]
        };
        return lineModel;
    } else if (type == 'pie') {
        //饼图
        const pieModel = {
            color: ['#53c1e6', '#fec868', '#fa7264', '#7853e1', '#76d6d2', '#1ba0c1', '#295c9d', '#ec915c', '#ebcb5c'],
            title: {
                text: '',
                left: 'center',
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#fff'
                }
            },
            grid: {
                left: '1%',
                right: '1%',
                bottom: '1%',
                top: '5%',
                containLabel: true
            },
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b}: {c} ({d}%)",
                textStyle: {
                    fontSize: '36',
                }
            },
            legend: {
                type: 'scroll',
                orient: 'vertical',
                right: '10%',
                top: 20,
                bottom: 20,
                data: [],
                textStyle: {
                    // fontWeight: 150,
                    fontSize: 36,
                    color: '#fff',
                    padding: 7
                }
            },
            series: [
                {
                    name: "",
                    type: 'pie',
                    radius: ['50%', '75%'],
                    center: ['30%', '50%'],
                    hoverAnimation:false,//hover动画效果关闭
                    data: [],
                    label: {
                        normal: {
                            show: false,
                            textStyle: {
                                fontWeight: 150,
                                fontSize: 36,
                                color: '#fff'
                            },
                            formatter: '{b} {d}%'
                        }
                    },
                }
            ]
        };
        return pieModel;
    } else if (type == 'bar_line') {
        //柱状图与折现图结合
        const barLineModel = {
            color: ['#53c1e6', '#fec868', '#53c1e6', '#fec868', '#76d6d2', '#1ba0c1', '#295c9d', '#ec915c', '#ebcb5c'],
            title: {
                text: '',
                left: 'center',
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#fff'
                }
            },
            grid: {
                left: '2%',
                right: '2%',
                bottom: '1%',
                top: '10%',
                containLabel: true
            },
            tooltip: {
                trigger: 'axis',
                textStyle: {
                    fontSize: '36'
                }
            },
            xAxis: [
                {
                    type: 'category',
                    data: [],
                    axisPointer: {
                        type: 'shadow'
                    },
                    axisLabel: {
                        show: true,
                        interval: 0, // 强制显示所有标签
                        textStyle: {
                            color: '#fff',
                            fontSize: 36
                        },
                        formatter:function(value) {
                            var v = value.substring(0, 7) + '...';
                            return value.length > 7 ? v : value
                        }
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#bbb',
                            width: 2, // 这里是为了突出显示加上的
                        }
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    name: '',
                    // interval: 200,
                    axisLabel: {
                        formatter: '{value}',
                        textStyle: {
                            fontSize: '36',
                            fontWeight: '500',
                            color: '#bbb'
                        }
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#bbb',
                            width: 2, // 这里是为了突出显示加上的
                        }
                    }
                },
                {
                    type: 'value',
                    name: '',
                    // min: 0,
                    // max: 25,
                    // interval: 10,
                    axisLabel: {
                        formatter: '{value}',
                        textStyle: {
                            fontSize: '36',
                            fontWeight: '500',
                            color: '#bbb'
                        }
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#bbb',
                            width: 2, // 这里是为了突出显示加上的
                        }
                    }
                }
            ],
            legend: {
                orient: 'horizontal',
                data: [],
                textStyle: {
                    fontWeight: 150,
                    fontSize: 36,
                    color: '#fff',
                    padding: 7
                }
            },
            series: []
        };
        return barLineModel;
    } else {
        //返回默认
        return getDefaultOption();
    }
}
export function chooseModelOption3(type) {
    if (type == 'bar') {
        //柱状 此处和默认option对象是一致的
        const barModel = {
            color: ["#22bae8", "#02E942", "#FFA800"],
            title: {
                text: '',
                left: 'center',
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#fff'
                }
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: { // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
                },
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#bbb'
                }
            },
            grid: {
                left: '1%',
                right: '1%',
                bottom: '1%',
                top: '5%',
                containLabel: true
            },
            xAxis: [{
                type: 'category',
                data: [], // 名称
                axisLabel: {
                    show: true,
                    interval: 0, // 强制显示所有标签
                    //rotate: 30, // 角度
                    textStyle: {
                        color: '#fff',
                        fontSize: 30
                    },
                    formatter:function(value) {
                        var v = value.substring(3, 13);
                        return value.length > 8 ? v : value
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: '#bbb',
                        width: 2, // 这里是为了突出显示加上的
                    }
                }
            }],
            yAxis: [{
                type: 'value',
                min: 0,
                splitLine: {
                    //show: false
                }, //去除网格线
                nameTextStyle: {
                    color: '#bbb',
                    fontSize: 36
                },
                axisLabel: {
                    formatter: '{value}',
                    textStyle: {
                        fontSize: '36',
                        fontWeight: '500',
                        color: '#bbb'
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#bbb',
                        width: 2, // 这里是为了突出显示加上的
                    }
                },
                axisTick: {
                    show: false,
                }
            }],
            series: [{
                name: '',
                type: 'bar',
                data: [],
                barWidth: '30%',//柱图宽度
                barMinHeight:10,
                barMaxWidth:45,
                itemStyle: {
                    normal: {
                        color: function(params) {
                            var index_color = params.value;
                            if(index_color*1>=0){
                                return '#22bae8';
                            }else {
                                return '#D76A62';
                            }
                        },
                        barBorderRadius: 6,
                        label: {
                            show: false,
                            position: 'top',
                            textStyle: {
                                color: '#fff',
                                fontSize: '36',
                                fontFamily: '微软雅黑',
                            },
                        },
                    }
                }
            }]
        };
        return barModel;
    } else if (type == 'line') {
        //线图
        const lineModel = {
            color: ["#fec868", "#02E942", "#FFA800"],
            title: {
                text: '',
                left: 'center',
                top:20,
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#fff'
                }
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: { // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
                },
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#bbb'
                }
            },
            grid: {
                left: '1%',
                right: '1%',
                bottom: '1%',
                top: '5%',
                containLabel: true
            },
            /*legend : {
              data: [],
              top : '8%',
              textStyle : {
                fontSize : '15',
                fontWeight : '500',
                color : '#fff'
              }
            },*/
            xAxis: [{
                type: 'category',
                data: [], // 名称
                axisLabel: {
                    show: true,
                    interval: 0, // 强制显示所有标签
                    textStyle: {
                        color: '#fff',
                        fontSize: 36
                    },
                    formatter:function(value) {
                        var v = value.substring(0, 7) + '...';
                        return value.length > 7 ? v : value
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#bbb',
                        width: 2, // 这里是为了突出显示加上的
                    }
                }
            }],
            yAxis: [{
                type: 'value',
                min: 0,
                minInterval:1,//分割为整数
                nameGap:10,//坐标轴名字与坐标轴的距离
                name:'',//坐标轴名字
                splitLine: {
                    //show: false
                }, //去除网格线
                nameTextStyle: {
                    color: '#bbb',
                    fontSize: 36
                },
                axisLabel: {
                    formatter: '{value}',
                    textStyle: {
                        fontSize: '36',
                        fontWeight: '500',
                        color: '#bbb'
                    }
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#bbb',
                        width: 2, // 这里是为了突出显示加上的
                    }
                },
                axisTick: {
                    show: false
                }
            }],
            series: [{
                name: '',
                type: 'line',
                data: [],
//                    smooth: true,
                symbolSize: 10,//拐点大小
                itemStyle: {
                    normal: {
                        lineStyle: {
                            width: 7,//折线宽度
                        },
                        label: {
                            show: false,
                            position: 'top',
                            textStyle: {
                                color: '#fff',
                                // fontWeight:'500er',
                                fontSize: '36',
                                fontFamily: '微软雅黑',
                            }
                        }
                    }
                }
            },]
        };
        return lineModel;
    } else if (type == 'pie') {
        //饼图
        const pieModel = {
            color: ['#53c1e6', '#fec868', '#fa7264', '#7853e1', '#76d6d2', '#1ba0c1', '#295c9d', '#ec915c', '#ebcb5c'],
            title: {
                text: '',
                left: 'center',
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#fff'
                }
            },
            grid: {
                left: '1%',
                right: '1%',
                bottom: '1%',
                top: '5%',
                containLabel: true
            },
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b}: {c} ({d}%)",
                textStyle: {
                    fontSize: '36',
                }
            },
            legend: {
                type: 'scroll',
                orient: 'vertical',
                right: '10%',
                top: 20,
                bottom: 20,
                data: [],
                textStyle: {
                    // fontWeight: 150,
                    fontSize: 36,
                    color: '#fff',
                    padding: 7
                }
            },
            series: [
                {
                    name: "",
                    type: 'pie',
                    radius: ['45%', '65%'],
                    center: ['30%', '50%'],
                    hoverAnimation:false,//hover动画效果关闭
                    data: [],
                    label: {
                        normal: {
                            show: false,
                            textStyle: {
                                fontWeight: 150,
                                fontSize: 36,
                                color: '#fff'
                            },
                            formatter: '{b} {d}%'
                        }
                    },
                }
            ]
        };
        return pieModel;
    } else if (type == 'bar_line') {
        //柱状图与折现图结合
        const barLineModel = {
            color: ['#53c1e6', '#fec868', '#53c1e6', '#fec868', '#76d6d2', '#1ba0c1', '#295c9d', '#ec915c', '#ebcb5c'],
            title: {
                text: '',
                left: 'center',
                textStyle: {
                    fontSize: '36',
                    fontWeight: '500',
                    color: '#fff'
                }
            },
            grid: {
                left: '2%',
                right: '2%',
                bottom: '1%',
                top: '10%',
                containLabel: true
            },
            tooltip: {
                trigger: 'axis',
                textStyle: {
                    fontSize: '36'
                }
            },
            xAxis: [
                {
                    type: 'category',
                    data: [],
                    axisPointer: {
                        type: 'shadow'
                    },
                    axisLabel: {
                        show: true,
                        interval: 0, // 强制显示所有标签
                        textStyle: {
                            color: '#fff',
                            fontSize: 36
                        },
                        formatter:function(value) {
                            var v = value.substring(0, 7) + '...';
                            return value.length > 7 ? v : value
                        }
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#bbb',
                            width: 2, // 这里是为了突出显示加上的
                        }
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    name: '',
                    // interval: 200,
                    axisLabel: {
                        formatter: '{value}',
                        textStyle: {
                            fontSize: '36',
                            fontWeight: '500',
                            color: '#bbb'
                        }
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#bbb',
                            width: 2, // 这里是为了突出显示加上的
                        }
                    }
                },
                {
                    type: 'value',
                    name: '',
                    // min: 0,
                    // max: 25,
                    // interval: 10,
                    axisLabel: {
                        formatter: '{value}',
                        textStyle: {
                            fontSize: '36',
                            fontWeight: '500',
                            color: '#bbb'
                        }
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#bbb',
                            width: 2, // 这里是为了突出显示加上的
                        }
                    }
                }
            ],
            legend: {
                orient: 'horizontal',
                data: [],
                textStyle: {
                    fontWeight: 150,
                    fontSize: 36,
                    color: '#fff',
                    padding: 7
                }
            },
            series: []
        };
        return barLineModel;
    } else {
        //返回默认
        return getDefaultOption();
    }
}

/**
 * echarts 实例化方法
 * @param elementId  生成图表的dom元素id
 * @param option     echarts插件所用option
 */
export function initEcharts(elementId, option) {
    var chartContent = echarts.getInstanceByDom(document.getElementById(elementId));
    if (chartContent == null) {
        chartContent = echarts.init(document.getElementById(elementId));
    }
    chartContent.clear();
    chartContent.setOption(option);
    return chartContent;
}
/**
 * echarts 实例化方法
 * @param elementId  生成图表的dom元素id
 * @param option     echarts插件所用option
 */
export function initEchartsByElementId(elementId) {
    var chartContent = echarts.getInstanceByDom(document.getElementById(elementId));
    if (chartContent == null) {
        chartContent = echarts.init(document.getElementById(elementId));
    }
    chartContent.clear();
    return chartContent;
}
/**
 * echarts 实例化方法
 * @param element  生成图表的dom元素
 * @param option     echarts插件所用option
 */
export function initEchartsByObj(element, option){
	var chartContent = echarts.getInstanceByDom(element);
	if (chartContent == null) {
	    chartContent = echarts.init(element);
	}
	chartContent.clear();
	chartContent.setOption(option);
	return chartContent;
}
/**
 * 返回新默认option
 */
export function settingOption() {
    var newOption = charts_utils_l.getDefaultOption();
    return newOption;
}

/**
 * 返回模板 Oprion
 * @param chartsType
 * @returns {*}
 */
export function settingModelOption(chartsType) {
    var newOption = charts_utils_l.chooseModelOption(chartsType);
    return newOption;
}

/**
 * 返回模板 Oprion
 * @param chartsType
 * @returns {*}
 */
export function settingModelOption2(chartsType) {
    var newOption = charts_utils_l.chooseModelOption2(chartsType);
    return newOption;
}

/**
 * 返回模板 Oprion
 * @param chartsType
 * @returns {*}
 */
export function settingModelOption3(chartsType) {
    var newOption = charts_utils_l.chooseModelOption3(chartsType);
    return newOption;
}


/**
 * 给图表绑定事件
 * @param elementId     图表所用的dom元素id
 * @param eventName     事件名称“click”，“change”等等
 * @param event         事件方法
 */
export function addChartsEvents(elementId, eventName, event) {
    var chartContent = echarts.getInstanceByDom(document.getElementById(elementId));
    if (chartContent == null) {
        chartContent = echarts.init(document.getElementById(elementId));
    }
    chartContent.on(eventName, function (params) {
        event(params);
    })
}

/**
 * dom 中没有数据的时候显示 没有数据友好提示
 * @param elementId
 */
export  function showFriendlyReminder(elementId){
    try {
        let domObj = document.getElementById(elementId);
        let height=domObj.offsetHeight+'px';
        let width=domObj.offsetWidth+'px';
        let contentStr = '<div id="friendlyReminder" style="vertical-align: middle;display: table-cell;width:'+width+';height:'+height+'">\n' +
            '    <p style="font-size: 80px;text-align: center;">暂无数据</p>\n' +
            '</div>';
        domObj.innerHTML = contentStr;
    } catch (e) {
        //什么都不做
        console.log("添加友好提示失败！可能由于没有此id对应的dom元素");
    }
}

/**
 * 去除dom 元素下的友好提示
 * @param elementId
 */
export  function removeFriendlyReminder(elementId){
    try {
        let domObj = document.getElementById(elementId);
        //判断dom元素下有没有提示，有就去除提示
        if(domObj.querySelector("#friendlyReminder")){
            domObj.removeAttribute('_echarts_instance_');//去除echats 容器缓存(echats 专用)
            domObj.removeChild(document.getElementById('friendlyReminder'));
        }
    } catch (e) {
        //什么都不做
        console.log("去除友好提示失败");
    }
}

/**
 * 格式化数字，三位一逗号
 * @param num
 * @returns {string}
 */
export function fnToThousands(num) {
    var num = (num || 0).toString(), result = '';
    while (num.length > 3) {
        result = ',' + num.slice(-3) + result;
        num = num.slice(0, num.length - 3);
    }
    if (num) { result = num + result; }
    return result;
}

//==============echart tool 工具方法     end==========================
